package com.iflyings.android.util

import android.util.Log
import com.iflyings.android.util.SystemUtils.getProperty
import com.iflyings.android.util.SystemUtils.setProperty

object LogHelper {
    private var TAG_DEFAULT = "test"

    fun setTag(tag: String) {
        TAG_DEFAULT = tag
    }

    fun setLogcatEnable(enable: Boolean) {
        if (enable) {
            setProperty("log.tag.$TAG_DEFAULT", "V")
        } else {
            setProperty("log.tag.$TAG_DEFAULT", "W")
        }
    }

    fun isLogcatEnable()  = "V" == getProperty("log.tag.$TAG_DEFAULT", "V")

    ////////////////////////////////////////////////////////////////
    fun v(desc: String) = v(TAG_DEFAULT, desc)
    fun v(tr: Throwable) = v(TAG_DEFAULT, tr)
    fun v(tag: String, desc: String) = Log.v(tag, desc)
    fun v(desc: String, tr: Throwable) = v(TAG_DEFAULT, desc, tr)
    fun v(tag: String, desc: String, tr: Throwable) = Log.v(tag, desc, tr)
    ////////////////////////////////////////////////////////////////
    fun d(desc: String) = d(TAG_DEFAULT, desc)
    fun d(tr: Throwable) = d(TAG_DEFAULT, tr)
    fun d(tag: String, desc: String) = Log.d(tag, desc)
    fun d(desc: String, tr: Throwable) = d(TAG_DEFAULT, desc, tr)
    fun d(tag: String, desc: String, tr: Throwable) = Log.d(tag, desc, tr)
    ////////////////////////////////////////////////////////////////
    fun i(desc: String) = i(TAG_DEFAULT, desc)
    fun i(tr: Throwable) = i(TAG_DEFAULT, tr)
    fun i(tag: String, desc: String) = Log.i(tag, desc)
    fun i(desc: String, tr: Throwable) = i(TAG_DEFAULT, desc, tr)
    fun i(tag: String, desc: String, tr: Throwable) = Log.i(tag, desc, tr)
    ////////////////////////////////////////////////////////////////
    fun w(desc: String) = w(TAG_DEFAULT, desc)
    fun w(tr: Throwable) = w(TAG_DEFAULT, tr)
    fun w(tag: String, desc: String) = Log.w(tag, desc)
    fun w(desc: String, tr: Throwable) = w(TAG_DEFAULT, desc, tr)
    fun w(tag: String, desc: String, e: Throwable) = Log.w(tag, desc, e)
    ////////////////////////////////////////////////////////////////
    fun e(desc: String) = e(TAG_DEFAULT, desc)
    fun e(tr: Throwable) = e(TAG_DEFAULT, tr)
    fun e(tag: String, desc: String) = Log.e(tag, desc)
    fun e(desc: String, tr: Throwable) = e(TAG_DEFAULT, desc, tr)
    fun e(tag: String, desc: String, tr: Throwable) = Log.e(tag, desc, tr)
}